#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <colors>
#include <PowerupsX>

#define PREFIX "{olive}PowerupsX {default}>{green} "

new AbilityAnti;

public Plugin:myinfo= 
{
	name="PowerupsXL Anti",
	author="Skydive",
	description="PowerupsX Anti Ability",
	version="1.0",
	url=""
};

public OnPluginStart()
{
	NativeIncStart();
	
	AbilityAnti = PX_RegisterAbility("AbilityAbilityRemoval");
	PX_SetAbilityName(AbilityAnti,"Ability Removal");
	PX_SetAbilityDescription(AbilityAnti,"Chance: Level*10.");
	PX_SetAbilityUsage(AbilityAnti,"Kill Others for a chance to remove their Ability.");
	PX_AbilityUseColor(AbilityAnti,true);
	PX_SetAbilityColor(AbilityAnti,255,0,255,255);
	PX_SetAbilityMaxLevel(AbilityAnti,8);
	
	HookEvent("player_death",Event_PlayerDeath);
}

public Event_PlayerDeath(Handle:event,const String:name[],bool:dontBroadcast)
{
	new victim = GetClientOfUserId(GetEventInt(event,"userid"));
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new Level = PX_GetLevel(attacker, PX_GetAbility(attacker));
	
	if(victim == 0) { return; }
	if(attacker == 0) { return; }
	
	if(GetClientTeam(victim) != GetClientTeam(attacker))
	{
		new i = Math_GetRandomInt(0, 100);
		if( i < Level*10 )
		{
			if(PX_GetAbility(attacker) == AbilityAnti && PX_GetAbility(victim) != PX_GetRegisteredAbility("AbilityNone"))
			{
				decl String:VictimName[MAX_NAME_LENGTH];
				decl String:AttackerName[MAX_NAME_LENGTH];
				
				GetClientName(victim,VictimName,sizeof(AttackerName));
				GetClientName(attacker,AttackerName,sizeof(AttackerName));
				
				PX_SetAbility(victim,0);
				CS_SetClientClanTag(victim, "None");
				CPrintToChat(attacker, "%s{green}You Removed {lightgreen}%s's {green}Ability!", PREFIX,VictimName);
				CSkipNextClient(attacker); CPrintToChatAll("%s{lightgreen}%s {green}Removed {lightgreen}%s's {green}Ability!", PREFIX,AttackerName,VictimName);
			}
			if(PX_GetAbility(victim) == AbilityAnti)
			{
				decl String:VictimName[MAX_NAME_LENGTH];
				decl String:AttackerName[MAX_NAME_LENGTH];
				
				GetClientName(victim,VictimName,sizeof(AttackerName));
				GetClientName(attacker,AttackerName,sizeof(AttackerName));
				
				PX_SetAbility(victim,0);
				CS_SetClientClanTag(victim, "None");
				CPrintToChat(attacker, "%s{green} You Removed {lightgreen}%s's {green}Ability!", PREFIX,VictimName);
				CSkipNextClient(attacker); CPrintToChatAll("%s{lightgreen}%s {green}Removed {lightgreen}%s's {green}Ability.", PREFIX,AttackerName,VictimName);
			}
		}
	}
}